'use strict';

module.exports = {
  up: (queryInterface, Sequelize) => {
    return queryInterface.sequelize.transaction((t) => {
      return Promise.all([
        
           queryInterface.addColumn('CorporateEntityUsers', 'UserId', {
            type: Sequelize.INTEGER,
            references: {
              model: 'Users', // name of Target model
              key: 'id', // key in Target model that we're referencing
            },
            onUpdate: 'CASCADE',
            onDelete: 'SET NULL',
           }, { transaction: t }),
           queryInterface.addColumn('CorporateEntityUsers', 'CorporateEntityId', {
            type: Sequelize.INTEGER,
            references: {
              model: 'CorporateEntities', // name of Target model
              key: 'id', // key in Target model that we're referencing
            },
            onUpdate: 'CASCADE',
            onDelete: 'SET NULL',
           }, { transaction: t }),
         
          
      ])
    })
  },

  down: (queryInterface, Sequelize) => {
    return queryInterface.sequelize.transaction((t) => {
      return Promise.all([
          queryInterface.removeColumn('CorporateEntityUsers', 'UserId',
           { transaction: t }),
          queryInterface.removeColumn('CorporateEntityUsers', 'CorporateEntityId',
           { transaction: t }),
        
      ])
    })
  }
};
